﻿@model _8_21_Classwork_Cafe.Models.CafeShop
@{
    ViewBag.Title = "Details";
}

<h2>Details</h2>
<div>
    <table>
        <tr>
            <td style="height:50px;width:50px;"><img class="img-responsive" src="@Model.Image" /></td>
            <td>@Model.Name</td>
            <td>@Model.Info</td>
        </tr>
    </table>
    <button class="pull-right btn btn-warning" onclick="location.href='/Home/AddReview/@Model.ID'">Add Review</button>
</div>

<div>
    @if (@Model.AvgRating() == 1)
    {
        <div>Average Rating &#9733&#9734&#9734&#9734&#9734</div><br />
    }
    else if (@Model.AvgRating() == 2)
    {
        <div>Average Rating &#9733&#9733&#9734&#9734&#9734</div><br />
    }
    else if (@Model.AvgRating() == 3)
    {
        <div>Average Rating &#9733&#9733&#9733&#9734&#9734</div><br />
    }
    else if (@Model.AvgRating() == 4)
    {
        <div>Average Rating &#9733&#9733&#9733&#9733&#9734</div><br />
    }
    else if (@Model.AvgRating() == 5){
        <div>Average Rating &#9733&#9733&#9733&#9733&#9733</div><br />
    }
</div>

<h3>Reviews</h3>
@if (Model.reviews != null)
{
    <table class="table table-striped">
        <tr>
            <th>User</th>
            <th>Comment</th>
            <th>Rating</th>
        </tr>
        @foreach (var r in Model.reviews)
        {
            <tr>
                <td>@r.UserName</td>
                <td>@r.UserReview</td>
                @if (@r.Rating == 1)
                {
                    <td>&#9733&#9734&#9734&#9734&#9734</td>
                }
                else if (@r.Rating == 2)
                {
                    <td>&#9733&#9733&#9734&#9734&#9734</td>
                }
                else if (@r.Rating == 3)
                {
                    <td>&#9733&#9733&#9733&#9734&#9734</td>
                }
                else if (@r.Rating == 4)
                {
                    <td>&#9733&#9733&#9733&#9733&#9734</td>
                }
                else if (@r.Rating == 5)
                {
                    <td>&#9733&#9733&#9733&#9733&#9733</td>
                }
            </tr>
        }
    </table>
}
